/*
 * @lc app=leetcode.cn id=125 lang=typescript
 *
 * [125] 验证回文串
 */

// @lc code=start
function isPalindrome(s: string): boolean {
    let i = 0;
    let j = s.length - 1;
    while (i < j) {
        const a1 = isValidOne(s[i]);
        const a2 = isValidOne(s[j]);
        if (a1 === false) {
            i++;
            continue;
        }
        if (a2 === false) {
            j--;
            continue;
        }
        if (a1 !== a2) return false;
        i++;
        j--;
    }
    return true;
}

const isValidOne = (s: string) => {
    const code = s.charCodeAt(0);
    if (code >= 48 && code <= 57) return code;
    if (code >= 97 && code <= 122) return code - 32;
    if (code >= 65 && code <= 90) return code;
    return false;
};
// @lc code=end
